package wli.web.util;

import java.util.*;

public class MyHtml {

	private static String month[] = { "January", "February", "March", "April",
			"May", "June", "July", "August", "September", "October",
			"November", "December" };

	public static StringBuffer getPageHead(String title, String script,
			String align, StringBuffer body) {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<html><head><title>" + title + "</title>");
		if (script.length() > 1) {
			sb.append("\n<SCRIPT>" + script + "</SCRIPT>");
		}
		sb.append("\n</head><body>");
		if (align.length() > 1) {
			sb.append("\n<" + align + ">");
		}
		sb.append(body);
		if (align.length() > 1) {
			sb.append("\n</" + align + ">");
		}
		sb.append("\n</body></html>");
		return sb;
	}

	public static StringBuffer getTextBox(String name, String init,
			String size, String mxsize) {
		StringBuffer sb = new StringBuffer();
		if (init == null) {
			init = "";
		}
		sb.append("\n<input type='text' name='" + name + "' value='" + init
				+ "' size='" + size + "' maxLength='" + mxsize + "'>");
		return sb;
	}

	public static StringBuffer getTextBox(String name, String init, int size,
			int mxsize) {
		StringBuffer sb = new StringBuffer();
		if (init == null) {
			init = "";
		}
		sb.append("\n<input type='text' name='" + name + "' value='" + init
				+ "' size='" + size + "' maxLength='" + mxsize + "'>");
		return sb;
	}

	public static StringBuffer getTextArea(String name, String init, int rows,
			int cols) {
		StringBuffer sb = new StringBuffer();
		if (init == null) {
			init = "";
		}
		sb.append("<TEXTAREA name='" + name + "' rows='" + rows + "' cols='"
				+ cols + "'>");
		sb.append(init);
		sb.append("</TEXTAREA>");
		return sb;
	}

	public static StringBuffer getOptions(String name, Hashtable hs) {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<select name=" + name + " size=1>");
		String temp = null;
		Enumeration enuma = hs.keys();
		while (enuma.hasMoreElements()) {
			temp = (String) enuma.nextElement();
			sb.append("\n<option value=" + hs.get(temp) + ">" + temp
					+ "</option>");
		}
		sb.append("\n</select>");
		return sb;
	}

	public static StringBuffer getOptions(String name, String options,
			String dim, boolean multiple, String default_value, String more) {
		StringBuffer sb = new StringBuffer();
		if (multiple) {
			sb.append("\n<select name='" + name + "' size='1' multiple " + more
					+ ">");
		} else {
			sb.append("\n<select name='" + name + "' " + more + ">");
		}
		if (default_value == null) {
			sb.append("\n<option selected>--------</option>");
		} else {
			sb.append("\n<option>--------</option>");
		}
		String temp = null;
		StringTokenizer tokens = new StringTokenizer(options, dim);
		while (tokens.hasMoreTokens()) {
			temp = tokens.nextToken();
			if (temp != null && temp.length() > 0) {
				if (default_value != null && temp.equals(default_value)) {
					sb.append("\n<option selected>" + temp + "</option>");
				} else {
					sb.append("\n<option>" + temp + "</option>");
				}
			}
		}

		sb.append("\n</select>");
		return sb;
	}

	public static StringBuffer VectorToTable(Vector vv) {
		StringBuffer sbf = new StringBuffer();
		if (vv == null || vv.isEmpty()) {
			return sbf;
		}

		sbf.append("<TABLE>");
		Enumeration enum1 = vv.elements();
		Enumeration enum2 = null;
		while (enum1.hasMoreElements()) {
			enum2 = ((Vector) enum1.nextElement()).elements();
			sbf.append("<TR>");
			while (enum2.hasMoreElements()) {
				sbf.append("<TD>" + enum2.nextElement() + "</TD>");
			}
			sbf.append("</TR>");
		}
		sbf.append("</TABLE>");
		return sbf;
	}

	public static StringBuffer getOptions(String name, Vector optionV,
			boolean multiple, String default_value) {
		StringBuffer sb = new StringBuffer();
		if (multiple) {
			sb.append("\n<select name='" + name
					+ "' size='1' multiple style='font-size: 8pt'>");
		} else {
			sb.append("\n<select name='" + name
					+ "' size='1' style='font-size: 8pt'>");
		}

		if (default_value == null) {
			sb.append("\n<option selected>--------</option>");
		} else {
			sb.append("\n<option>--------</option>");
		}

		String temp = null;
		Enumeration enuma = optionV.elements();
		while (enuma.hasMoreElements()) {
			temp = (String) enuma.nextElement();
			if (temp != null && temp.length() > 0) {
				if (default_value != null && temp.equals(default_value)) {
					sb.append("\n<option selected>" + temp + "</option>");
				} else {
					sb.append("\n<option>" + temp + "</option>");
				}
			}
		}

		sb.append("\n</select>");
		return sb;
	}

	public static StringBuffer getYearOption(int m, int n) {
		Calendar c = Calendar.getInstance();
		int y = c.get(Calendar.YEAR);

		StringBuffer sb = new StringBuffer();
		for (int i = m; i <= n; i++) {
			c.set((y - i), 0, 1, 0, 0);
			sb.append("\n<option value=" + c.get(Calendar.YEAR) + " O"
					+ c.get(Calendar.YEAR) + ">" + c.get(Calendar.YEAR)
					+ "</option>");
		}

		return sb;
	}

	public static StringBuffer getBirthYearOption(String selected) {
		int n = -1;
		if (selected != null && selected.length() > 0) {
			if ((new MyUserInputCheck()).checkNumber(selected)) {
				n = Integer.parseInt(selected);
			}
		}

		Calendar c = Calendar.getInstance();
		int y = c.get(Calendar.YEAR);

		StringBuffer sb = new StringBuffer();
		for (int i = 1; i <= 120; i++) {
			c.set((y - i), 0, 1, 0, 0);
			if (n == c.get(Calendar.YEAR)) {
				sb.append("\n<option value=" + c.get(Calendar.YEAR)
						+ " selected>" + c.get(Calendar.YEAR) + "</option>");
			} else {
				sb.append("\n<option value=" + c.get(Calendar.YEAR) + ">"
						+ c.get(Calendar.YEAR) + "</option>");
			}
		}

		return sb;
	}

	public static StringBuffer getBirthMonthOption(String selected) {
		int n = -1;
		if (selected != null && selected.length() > 0) {
			if ((new MyUserInputCheck()).checkNumber(selected)) {
				n = Integer.parseInt(selected);
			}
		}

		StringBuffer sb = new StringBuffer();
		for (int i = 0; i <= 11; i++) {
			if (n == i + 1) {
				sb.append("\n<option value=" + (i + 1) + " selected>"
						+ month[i] + "</option>");
			} else {
				sb.append("\n<option value=" + (i + 1) + ">" + month[i]
						+ "</option>");
			}
		}
		return sb;
	}

	public static StringBuffer getBirthDayOption(String selected) {
		int n = -1;
		if (selected != null && selected.length() > 0) {
			if ((new MyUserInputCheck()).checkNumber(selected)) {
				n = Integer.parseInt(selected);
			}
		}

		StringBuffer sb = new StringBuffer();

		for (int i = 1; i <= 31; i++) {
			if (n == i) {
				sb.append("\n<option value=" + i + " selected>" + i
						+ "</option>");
			} else {
				sb.append("\n<option value=" + i + ">" + i + "</option>");
			}
		}
		return sb;
	}

	public static StringBuffer getBirthYearOption(int age) {
		Calendar c = Calendar.getInstance();
		int y = c.get(Calendar.YEAR);

		StringBuffer sb = new StringBuffer();
		for (int i = age; i <= 120; i++) {
			c.set((y - i), 0, 1, 0, 0);
			sb.append("\n<option value=" + c.get(Calendar.YEAR) + " O"
					+ c.get(Calendar.YEAR) + ">" + c.get(Calendar.YEAR)
					+ "</option>");
		}

		return sb;
	}

	public static StringBuffer getCardTypeOption() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<option value='American Express'>American Express</option>");
		sb.append("\n<option value='Discover'>Discover</option>");
		sb.append("\n<option value='Master Card'>MasterCard</option>");
		sb.append("\n<option value='Visa'>Visa</option>");
		return sb;
	}

	public static StringBuffer getHairColor() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<option>Auburn");
		sb.append("\n<option>Black");
		sb.append("\n<option>Blonde");
		sb.append("\n<option>Light brown");
		sb.append("\n<option>Dark brown");
		sb.append("\n<option>Red");
		sb.append("\n<option>White/gray");
		sb.append("\n<option>No answer");
		return sb;
	}

	public static StringBuffer getEthnicity() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<option>African American (black)");
		sb.append("\n<option>Asian");
		sb.append("\n<option>Caucasian (white)");
		sb.append("\n<option>East Indian");
		sb.append("\n<option>Hispanic/Latino");
		sb.append("\n<option>Middle Eastern");
		sb.append("\n<option>Native American");
		sb.append("\n<option>Pacific Islander");
		sb.append("\n<option>Other");
		sb.append("\n<option>No answer");
		return sb;
	}

	public static StringBuffer getMaritalStatus() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<option>Single");
		sb.append("\n<option>Divorced");
		sb.append("\n<option>Widowed");
		sb.append("\n<option>Separated");
		sb.append("\n<option>No answer");
		return sb;
	}

	public static StringBuffer getEmploymentStatus() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<option>Full-time");
		sb.append("\n<option>Part-time");
		sb.append("\n<option>Homemaker");
		sb.append("\n<option>Retired");
		sb.append("\n<option>Self-employed");
		sb.append("\n<option>Student");
		sb.append("\n<option>Unemployed");
		sb.append("\n<option>Work at home");
		sb.append("\n<option>No answer");
		return sb;
	}

	public static StringBuffer makeLinkCell(String name, String link) {
		StringBuffer sbf = new StringBuffer();
		sbf.append("<TD align=center style='BORDER: 1px solid'>");
		sbf.append("\n<A href=" + link + " style='text-decoration: none;'>");
		sbf.append("\n&nbsp;" + name + "&nbsp;");
		sbf.append("\n</A>");
		sbf.append("\n</TD>");
		return sbf;
	}

	public static String error(String error) {
		return "<img src=/images/star.gif><I>" + error + "</I>";
	}

	public static StringBuffer makeLinkButton(String name, String link) {
		StringBuffer sbf = new StringBuffer();
		sbf.append("\n<TABLE cellSpacing=0 cellPadding=0>");
		sbf.append("\n<TR>");
		sbf.append("\n<TD align=center style='BORDER: 1px solid'>");
		sbf.append("\n<A href=" + link + " style='text-decoration: none'>");
		sbf.append("\n&nbsp;" + name + "&nbsp;");
		sbf.append("\n</A>");
		sbf.append("\n</TD>");
		sbf.append("\n</TR>");
		sbf.append("\n</TABLE>");
		return sbf;
	}

	public static StringBuffer getEducationOption() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<option value=0>High-School</option>");
		sb.append("\n<option value=1>College(2 years)</option>");
		sb.append("\n<option value=2>Bachelor</option>");
		sb.append("\n<option value=3>Master</option>");
		sb.append("\n<option value=4>Ph.D/Dr.</option>");
		return sb;
	}

	public static StringBuffer getEducationOption(String selected) {
		int n = -1;
		if (selected != null && selected.length() > 0) {
			if ((new MyUserInputCheck()).checkNumber(selected)) {
				n = Integer.parseInt(selected);
			}
		}

		StringBuffer sb = new StringBuffer();
		String options[] = { "High-School", "College(2 years)", "Bachelor",
				"Master", "Ph.D/Dr." };

		for (int i = 0; i < options.length; i++) {
			sb.append("\n<option value='" + i + "'");
			if (i == n) {
				sb.append(" selected");
			}
			sb.append(">" + options[i] + "</option>");
		}
		return sb;
	}

	public static StringBuffer getEducationOption(String name, String selected) {

		if (selected == null || selected.length() == 0) {
			selected = "--------";
		}

		StringBuffer sbf = new StringBuffer();
		String options[] = { "--------", "High-School", "College(2 years)",
				"Bachelor", "Master", "Ph.D/Dr." };
		sbf.append("\n<select name='" + name + "'  style='font-size: 8pt'>");

		for (int i = 0; i < options.length; i++) {
			if (options[i].equals(selected)) {
				sbf.append("\n<option selected>");
			} else {
				sbf.append("\n<option>");
			}
			sbf.append(options[i] + "</option>");
		}

		sbf.append("</select>");
		return sbf;
	}

	public static StringBuffer getOccupation() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<option value=oc01>Artistic / Musical / Writer");
		sb.append("\n<option value=oc02>Banking / Financial Services / Real Estate");
		sb.append("\n<option value=oc03>Clerical / Administrative");
		sb.append("\n<option value=oc04>Computer-related / Hardware / Software");
		sb.append("\n<option value=oc05>Construction / Craftsman");
		sb.append("\n<option value=oc06>Education / Academic Research");
		sb.append("\n<option value=oc07>Entertainment / Media");
		sb.append("\n<option value=oc08>Executive / Management");
		sb.append("\n<option value=oc09>Hospitality / Travel");
		sb.append("\n<option value=oc10>Legal Services");
		sb.append("\n<option value=oc11>Manufacturing / Distribution");
		sb.append("\n<option value=oc12>Medical / Health Services");
		sb.append("\n<option value=oc13>Political / Government / Military");
		sb.append("\n<option value=oc14>Sales / Marketing");
		sb.append("\n<option value=oc15>Technical / Science / Engineering");
		sb.append("\n<option value=oc16>Transportation");
		sb.append("\n<option value=oc98>Other");
		sb.append("\n<option value=oc99>No answer");
		return sb;
	}

	public static StringBuffer getAdvIndustry(String name, String init) {
		StringBuffer sbf = new StringBuffer();

		sbf.append("\n<select name='" + name + "'  style='font-size: 8pt'>");
		if (init == null) {
			sbf.append("\n<option selected></option>");
		} else {
			sbf.append("\n<option></option>");
		}
		Vector v = new Vector();
		v.add("Advertising");
		v.add("Aerospace");
		v.add("Agriculture");
		v.add("Automotive");
		v.add("Chemicals");
		v.add("Computers");
		v.add("Construction");
		v.add("Consumer Goods");
		v.add("Education");
		v.add("Electronics");
		v.add("Energy");
		v.add("Entertainment");
		v.add("Finance");
		v.add("Forest Products");
		v.add("Government");
		v.add("Health Services");
		v.add("Hospitality");
		v.add("Insurance");
		v.add("Marketing");
		v.add("Media");
		v.add("Medical");
		v.add("Military");
		v.add("Public Service");
		v.add("Publishing");
		v.add("Pharmaceutical Retail");
		v.add("Real Estate");
		v.add("Recreation");
		v.add("Services");
		v.add("Telecommunications");
		v.add("Travel");
		Enumeration enumb = v.elements();
		String temp = null;
		while (enumb.hasMoreElements()) {
			temp = (String) enumb.nextElement();

			if (init != null && temp.equals(init.trim())) {
				sbf.append("<option selected>" + temp + "</option>");
			} else {
				sbf.append("<option>" + temp + "</option>");
			}
		}
		sbf.append("</select>");
		return sbf;
	}

	public static StringBuffer getAdvBudget(String name, String init) {
		StringBuffer sbf = new StringBuffer();

		sbf.append("\n<select name='" + name + "'  style='font-size: 8pt'>");
		if (init == null) {
			sbf.append("\n<option selected></option>");
		} else {
			sbf.append("\n<option></option>");
		}
		Vector v = new Vector();
		v.add("$1k-");
		v.add("$1k-5k");
		v.add("$5k-10k");
		v.add("$10k-15k");
		v.add("$15k-20k");
		v.add("$20k+");

		Enumeration enuma = v.elements();
		String temp = null;
		while (enuma.hasMoreElements()) {
			temp = (String) enuma.nextElement();

			if (init != null && temp.equals(init.trim())) {
				sbf.append("<option selected>" + temp + "</option>");
			} else {
				sbf.append("<option>" + temp + "</option>");
			}
		}
		sbf.append("</select>");
		return sbf;
	}

	public static StringBuffer getUsState (String name, String init) {
	StringBuffer sbf = new StringBuffer();
	sbf.append("\n<select name='"+name+"'  style='font-size: 8pt'>");
	if(init == null) {
	    sbf.append("\n<option selected></option>");
	}
	else {
	    sbf.append("\n<option></option>");
	}
	Vector v = new Vector();
	v.add("International");
	v.add("AL");
	v.add("AK");
	v.add("AS");
	v.add("AZ");
	v.add("AR");
	v.add("CA");
	v.add("CO");
	v.add("CT");
	v.add("DE");
	v.add("DC");
	v.add("FM");
	v.add("FL");
	v.add("GA");
	v.add("GU");
	v.add("HI");
	v.add("ID");
	v.add("IL");
	v.add("IN");
	v.add("IA");
	v.add("KS");
	v.add("KY");
	v.add("LA");
	v.add("ME");
	v.add("MH");
	v.add("MD");
	v.add("MA");
	v.add("MI");
	v.add("MN");
	v.add("MS");
	v.add("MO");
	v.add("MT");
	v.add("NE");
	v.add("NV");
	v.add("NH");
	v.add("NJ");
	v.add("NM");
	v.add("NY");
	v.add("NC");
	v.add("ND");
	v.add("MP");
	v.add("OH");
	v.add("OK");
	v.add("OR");
	v.add("PW");
	v.add("PA");
	v.add("PR");
	v.add("RI");
	v.add("SC");
	v.add("SD");
	v.add("TN");
	v.add("TX");
	v.add("UT");
	v.add("VT");
	v.add("VI");
	v.add("VA");
	v.add("WA");
	v.add("WV");
	v.add("WI");
	v.add("WY");
	/*
	<option value="A0108176" SELECTED>Alabama
	<option value="A0108178">Alaska
	<option value="A0108181">Arizona
	<option value="A0108184">Arkansas
	<option value="A0108187">California
	<option value="A0108189">Colorado
	<option value="A0108191">Connecticut
	<option value="A0108194">Delaware
	<option value="A0108198">Florida
	<option value="A0108201">Georgia
	<option value="A0108204">Hawaii
	<option value="A0108207">Idaho
	<option value="A0108209">Illinois
	<option value="A0108211">Indiana
	<option value="A0108213">Iowa
	<option value="A0108215">Kansas
	<option value="A0108217">Kentucky
	<option value="A0108219">Louisiana
	<option value="A0108221">Maine
	<option value="A0108223">Maryland
	<option value="A0108225">Massachusetts
	<option value="A0108228">Michigan
	<option value="A0108230">Minnesota
	<option value="A0108232">Mississippi
	<option value="A0108234">Missouri
	<option value="A0108237">Montana
	<option value="A0108240">Nebraska
	<option value="A0108242">Nevada
	<option value="A0108244">New Hampshire
	<option value="A0108246">New Jersey
	<option value="A0108250">New Mexico
	<option value="A0108252">New York
	<option value="A0108254">North Carolina
	<option value="A0108256">North Dakota
	<option value="A0108258">Ohio
	<option value="A0108260">Oklahoma
	<option value="A0108262">Oregon
	<option value="A0108264">Pennsylvania
	<option value="A0108266">Rhode Island
	<option value="A0108268">South Carolina
	<option value="A0108270">South Dakota
	<option value="A0108274">Tennessee
	<option value="A0108277">Texas
	<option value="A0108279">Utah
	<option value="A0108281">Vermont
	<option value="A0108283">Virginia
	<option value="A0108286">Washington
	<option value="A0108289">West Virginia
	<option value="A0108291">Wisconsin
	<option value="A0108293">Wyoming
	*/

	Enumeration enumb = v.elements();
	String temp = null;
	while(enumb.hasMoreElements()) {
	    temp = (String)enumb.nextElement();    
	    if(init != null && temp.equals(init)) {
		sbf.append("<option selected>"+temp+"</option>");
	    }
	    else {
		sbf.append("<option>"+temp+"</option>");
	    }
	}
        sbf.append("</select>");
	return sbf;
    }

	public static StringBuffer getAnnualIncome() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<option value=inc1>Less than $24,999");
		sb.append("\n<option value=inc2>$25,000 to $34,999");
		sb.append("\n<option value=inc3>$35,000 to $49,999");
		sb.append("\n<option value=inc4>$50,000 to $74,999");
		sb.append("\n<option value=inc5>$75,000 to $99,999");
		sb.append("\n<option value=inc6>$100,000 to $149,999");
		sb.append("\n<option value=inc7>More than $150,000");
		sb.append("\n<option value=inc99>No answer");
		return sb;
	}

	public static StringBuffer getReligion() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<option>Buddhist");
		sb.append("\n<option>Christian");
		sb.append("\n<option>Jewish");
		sb.append("\n<option>Muslim");
		sb.append("\n<option>Hindu");
		sb.append("\n<option>None");
		sb.append("\n<option>Other");
		sb.append("\n<option>No answer");
		return sb;
	}

	public static StringBuffer getInterests() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<input type=checkbox name= value=>Friends");
		sb.append("\n<input type=checkbox name= value=>Dancing");
		sb.append("\n<input type=checkbox name= value=>Dining");
		sb.append("\n<input type=checkbox name= value=>Family");
		sb.append("\n<input type=checkbox name= value=>Movies");
		sb.append("\n<input type=checkbox name= value=>Music");
		sb.append("\n<input type=checkbox name= value=>Outdoor Activities");
		sb.append("\n<input type=checkbox name= value=>Photography");
		sb.append("\n<input type=checkbox name= value=>Reading");
		sb.append("\n<input type=checkbox name= value=>Sports");
		sb.append("\n<input type=checkbox name= value=>Theater");
		sb.append("\n<input type=checkbox name= value=>Travel");
		return sb;
	}

	public static StringBuffer getGenderOption(String selected) {
		String options[] = { "Male", "Female", "Other" };
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < options.length; i++) {
			if (selected != null && selected.equals(options[i])) {
				sb.append("\n<option selected>" + options[i] + "</option>");
			} else {
				sb.append("\n<option>" + options[i] + "</option>");
			}
		}
		return sb;
	}

	public static StringBuffer getCountryOption(String name, String init) {
	StringBuffer sbf = new StringBuffer();
	sbf.append("\n<select name='"+name+"'  style='font-size: 8pt'>");
	if(init == null || init.length()==0) {
	    init = "--------";
	}

	Vector v = new Vector();
	v.add("--------");
	v.add("United States");
	v.add("Argentina");
	v.add("Australia"); 
	v.add("Brazil");
	v.add("Canada");
	v.add("China");
	v.add("Denmark");
	v.add("France ");
	v.add("Germany");
	v.add("Greece");
	v.add("India");
	v.add("Italy");
	v.add("Japan");
	v.add("Korea");
	v.add("Mexico");
	v.add("New Zealand");
	v.add("Norway");
	v.add("Singapore");
	v.add("Spain");
	v.add("Sweden");
	v.add("United Kingdom");
	v.add("Other");

	Enumeration enuma = v.elements();
	String temp = null;
	while(enuma.hasMoreElements()) {
	    temp = (String)enuma.nextElement();    
	    if(init != null && temp.equals(init)) {
		sbf.append("<option selected>"+temp+"</option>");
	    }
	    else {
		sbf.append("<option>"+temp+"</option>");
	    }
	}
        sbf.append("</select>");
	return sbf;
    }

	public static StringBuffer getBadHabits() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<option>No");
		sb.append("\n<option>Socially");
		sb.append("\n<option>Daily");
		sb.append("\n<option>No answer");
		return sb;
	}

	public static StringBuffer getRelationCheckBoxs() {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<input type=checkbox name=relation>Committed");
		sb.append("\n<input type=checkbox name=relation>Friends");
		sb.append("\n<input type=checkbox name=relation>Just Dating");
		return sb;
	}

	public static StringBuffer getMetaKeyWords(int which) {
		StringBuffer sb = new StringBuffer();
		if (which == 1) { // dating
			sb.append("\n<meta name=\"keywords\" content=\"3wcenter.com, dating, personals, online dating, singles,");
			sb.append("\nlove, romance, friendship, relationship, personal ad, personal,");
			sb.append("\nmatchmaking, matchmaker, secure, attractive, single, find, date,");
			sb.append("\npeople, dating, photo, pictures, gay personal, photo personal,");
			sb.append("\nsearch, match, friend, quality, men seeking women, women seeking men,");
			sb.append("\nmen seeking men, women seeking women, dating service, gay, lesbian,");
			sb.append("\npartner, jewish, christian, chinese, matching, advice </meta>");
		}
		return sb;
	}

	public static StringBuffer tableWraper(int border_type, String bgcolor,
			String align, StringBuffer in) {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<TABLE  cellSpacing=0 cellPadding=0 border=0 width=100%>");
		sb.append("\n<TR>");
		if (border_type == 0) {
			sb.append("\n<TD align='" + align + "' bgcolor='" + bgcolor + "'>");
		}
		if (border_type == 1) {
			sb.append("\n<TD align='" + align + "' bgcolor='" + bgcolor
					+ "' style='BORDER-BOTTOM: 1px solid;'>");
		}
		if (border_type == 2) {
			sb.append("\n<TD align='"
					+ align
					+ "' bgcolor='"
					+ bgcolor
					+ "' style='BORDER-TOP: 1px solid; BORDER-BOTTOM: 1px solid;'>");
		}
		sb.append("\n\t" + in);
		sb.append("\n</TD>");
		sb.append("\n</TR>");
		sb.append("\n</TABLE>");
		return sb;
	}

	public static StringBuffer tableWraper(int border_type, String align,
			StringBuffer in) {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<TABLE border='0' width='100%'>");
		sb.append("\n<TR>");
		if (border_type == 0) {
			sb.append("\n<TD align='" + align + "'>");
		}
		if (border_type == 1) {
			sb.append("\n<TD align='" + align
					+ "' style='BORDER-BOTTOM: 1px solid;'>");
		}
		if (border_type == 2) {
			sb.append("\n<TD align='"
					+ align
					+ "' style='BORDER-TOP: 1px solid; BORDER-BOTTOM: 1px solid;'>");
		}
		sb.append("\n\t" + in);
		sb.append("\n</TD>");
		sb.append("\n</TR>");
		sb.append("\n</TABLE>");
		return sb;
	}

	public static StringBuffer pageCounter(int total_rows, String page_rows,
			String current_page, String call_back_link) {

		int pw = Integer.parseInt(page_rows);
		int cp = 1;

		if (current_page != null && MyStringCheck.isNumber(current_page)) {
			cp = Integer.parseInt(current_page);
		}

		return (pageCounter(total_rows, pw, cp, call_back_link));
	}

	public static StringBuffer pageCounter(int total_rows, int page_rows,
			int current_page, String call_back_link) {
		StringBuffer sb = new StringBuffer();

		sb.append("\n<TABLE>");
		sb.append("\n<TR><TD><B>Page No:</B></TD>\n");

		int tp = 0;
		if (total_rows % page_rows == 0) {
			tp = total_rows / page_rows;
		} else {
			tp = total_rows / page_rows + 1;
		}

		int list = 8;

		for (int j = 1; j <= tp; j++) {
			if (j == current_page) {
				sb.append("\n<TD><B>[" + j + "]</B></TD>\n");
			} else {
				sb.append("\n<TD><B>[<A href=" + call_back_link + "&pid=" + j
						+ ">" + j + "</A>]</B></TD>\n");
			}

			if (j >= list) {
				sb.append("\n<FORM method=post name=page_change action="
						+ call_back_link + ">");
				sb.append("\n<TD valign=top align=left>");
				sb.append("\n<SELECT name=pid onChange=this.form.submit(); style='font-size: 8px'>");
				sb.append("\n<OPTION value=1 selected>></OPTION>");
				for (int m = j + 1; m <= tp; m++) {
					if (current_page == m) {
						sb.append("\n<OPTION value=" + m + " selected>" + m
								+ "</OPTION>");
					} else {
						sb.append("\n<OPTION value=" + m + ">" + m
								+ "</OPTION>");
					}
				}
				sb.append("\n</SELECT></TD>");
				sb.append("\n</FORM>");
				break;
			}
		}

		sb.append("\n<TD><B>&nbsp;Total</B></TD><TD><B>[" + (tp)
				+ "]</B></TD><TD><B>Page(s)</B></TD></TR></TABLE>\n");

		StringBuffer sbf = new StringBuffer();
		sbf.append(tableWraper(1, "#EEEEEE", "center", sb));
		return sbf;
	}

	public static StringBuffer searchCounter(int total_found) {
		StringBuffer sb = new StringBuffer();

		sb.append("\n<TABLE border=0 style='color:#FFFFFF; font-size:12pt'>");
		sb.append("<TR><TD><B>Total Found:</B></TD>\n");
		sb.append("\n<TD><B>[" + total_found + "]</B></TD>");
		sb.append("<TD><B>Record(s)</B></TD></TR></TABLE>\n");

		StringBuffer sbf = new StringBuffer();
		sbf.append(tableWraper(1, "#EEEEEE", "center", sb));
		return sbf;
	}

	public static StringBuffer abcPageCounter(String current_page,
			String call_back_link) {
		int pg = 1;
		if (current_page != null) {
			pg = Integer.parseInt(current_page);
		}
		return (abcPageCounter(pg, call_back_link));
	}

	public static StringBuffer abcPageCounter(int current_page,
			String call_back_link) {
		String all_alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		StringBuffer sb = new StringBuffer();
		sb.append("\n<!---------------------- Alpha Page Counter ----------------------->");
		sb.append("\n<TABLE border='0' style='color:#FFFFFF'>");
		sb.append("\n<TR>");
		for (int j = 0; j < 26; j++) {
			if (j == (current_page - 1)) {
				sb.append("\n<TD>|" + all_alpha.substring(j, j + 1) + "</TD>\n");
			} else {
				sb.append("\n<TD>|<A href=" + call_back_link + "&pid="
						+ (j + 1) + ">");
				sb.append(all_alpha.substring(j, j + 1) + "</A></TD>\n");
			}
		}

		sb.append("\n</TR></TABLE>");
		sb.append("\n<!----------------------End of Alpha Page Counter ----------------------->");
		StringBuffer sbf = new StringBuffer();
		sbf.append(tableWraper(1, "#EEEEEE", "center", sb));
		return sbf;
	}

	public static StringBuffer historyButton(String button_name, int step) {
		StringBuffer sb = new StringBuffer();
		sb.append("\n<SCRIPT>\n");
		sb.append("\nfunction go_back() {\n");
		sb.append("\n  history.go(" + step + ");\n");
		sb.append("\n}\n");
		sb.append("\n</SCRIPT>\n");
		sb.append("\n<INPUT TYPE=button value=Back onClick=\"go_back()\"  style='font-size: 8pt'>\n");
		return sb;
	}

	public static StringBuffer folderDisplay(String[] fnames, String selected,
			int width, int height, StringBuffer cbf, String ctalign,
			String ctvalign) {

		int which = Integer.parseInt(selected);
		StringBuffer sb = new StringBuffer();
		sb.append("\n<TABLE border=0  cellSpacing=0 cellPadding=0>");
		sb.append("\n<TR>");
		int tf = fnames.length;
		for (int i = 0; i < tf; i++) {
			sb.append("\n<TD width=20></TD>");
			sb.append("\n<TD style='BORDER-LEFT: 2px solid; BORDER-RIGHT: 2px solid; BORDER-TOP: 2px solid;' align=center>");
			if (i == which) {
				sb.append(fnames[i].substring((fnames[i].indexOf(">") + 1),
						fnames[i].lastIndexOf("<")) + "</TD>");
			} else {
				sb.append(fnames[i] + "</TD>");
			}
		}
		sb.append("\n<TD width=20></TD>");
		sb.append("\n</TR>");
		sb.append("\n<TR>");
		sb.append("\n<TD style='BORDER-LEFT: 1px solid; BORDER-TOP: 1px solid;' colspan="
				+ (which * 2 + 1) + ">&nbsp</TD>");
		sb.append("\n<TD></TD>");
		sb.append("\n<TD style='BORDER-TOP: 1px solid; BORDER-RIGHT: 1px solid;' colspan="
				+ (2 * (tf - which)) + ">&nbsp;</TD>");
		sb.append("\n</TR>");
		sb.append("\n<TR><TD colspan="
				+ (2 * tf + 1)
				+ " style='BORDER-LEFT: 1px solid; BORDER-RIGHT: 1px solid; BORDER-BOTTOM: 1px solid;'");
		sb.append("\nwidth=" + width + " height=" + height + " align="
				+ ctalign + " valign=" + ctvalign + ">");
		sb.append("\n&nbsp;" + cbf);
		sb.append("\n</TD></TR>");
		sb.append("\n</TABLE>");
		return sb;
	}

	public static StringBuffer forumDisplay(String sid, String left,
			StringBuffer middle, String right) {

		StringBuffer sbf = new StringBuffer("");
		sbf.append("\n<FORM name=update_top_form method=post action=TopBarServlet target=topFrame>");
		sbf.append("\n<input type=hidden name=sid value=" + sid + ">");
		sbf.append("\n</FORM>");

		sbf.append("\n<TABLE cellSpacing=0 cellPadding=0 border=1 width=1080 style='font-size: 10pt'>");
		sbf.append("\n<TR><TD width=140 align=center valign=top>");
		sbf.append(left);
		sbf.append("\n</TD>");

		sbf.append("\n<TD align=center valign=top width=800 height=800>");
		sbf.append(middle);
		sbf.append("\n</TD>");
		sbf.append("\n<TD width=140 align=center valign=top>");
		sbf.append(right);
		sbf.append("\n</TD>");
		sbf.append("\n</TR>");
		sbf.append("\n</TABLE><BR>");
		sbf.append("<CENTER>");
		sbf.append("\n<img src=/servlet/ImageLoadServlet?image=/images/copy_right.gif border=0>");
		sbf.append("\n</CENTER>");

		sbf.append("\n<SCRIPT>");
		sbf.append("\ndocument.update_top_form.submit();");
		sbf.append("\n</SCRIPT>");
		return sbf;
	}

	public static StringBuffer forumDisplay(StringBuffer left,
			StringBuffer middle, StringBuffer right) {

		StringBuffer sbf = new StringBuffer("");

		sbf.append("<TABLE>");
		sbf.append("<TR>");
		sbf.append("<TD align='center' valign='top' style='BORDER: 1px solid #999999;' width='140'>");
		sbf.append(left);
		sbf.append("</TD>");

		// sbf.append("\n<TD align=center valign=top width=800 height=800>");
		sbf.append("<td align='center' valign='top' width='800' height='600' style='BORDER: 1px solid #999999;'>");
		sbf.append(middle);
		sbf.append("\n</TD>");
		// sbf.append("\n<TD width=140 align=center valign=top>");
		sbf.append("<td width='140' align='center' valign='top' style='BORDER: 1px solid #999999;'>");
		sbf.append(right);
		sbf.append("\n</TD>");
		sbf.append("\n</TR>");
		sbf.append("\n</TABLE>");
		return sbf;
	}

	public static StringBuffer htmlDisplay(String title,
			StringBuffer javascript, String sid, StringBuffer mainbf) {

		StringBuffer sbf = new StringBuffer("");
		sbf.append("\n<HTML><HEAD>");
		sbf.append("\n<TITLE>" + title + "</TITLE>");

		if (javascript != null) {
			sbf.append(javascript);
		}
		sbf.append("\n</HEAD><BODY>");

		sbf.append("\n<FORM name=update_top_form method=post action=TopBarServlet target=topFrame>");
		sbf.append("\n<input type=hidden name=sid value=" + sid + ">");
		sbf.append("\n</FORM>");

		if (mainbf != null) {
			sbf.append(mainbf);
		}

		sbf.append("\n<SCRIPT>");
		sbf.append("\ndocument.update_top_form.submit();");
		sbf.append("\n</SCRIPT>");

		sbf.append("\n</BODY></HTML>");
		return sbf;
	}

	public static StringBuffer replaceTopUrl(String url) {
		StringBuffer sbf = new StringBuffer();
		sbf.append("\n<SCRIPT>");
		sbf.append("\n\t top.location.replace(\"" + url + "\");");
		sbf.append("\n</SCRIPT>");
		return sbf;
	}
}
